#!/bin/bash

############################################################################
#
# 远程执行该脚本，请在命令行中直接执行以下命令：
#
#   curl -sSL https://gitee.com/tay3223/biubiubiu/raw/master/centos7-install-php81-pdns-recursor.sh | /bin/bash
#
#
############################################################################

sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo

mkdir -p "${HOME}"/bao
wget -P "${HOME}"/bao/  http://file.ttpai.work/d/tar/pdns/pdns-4.1.x-linux.tar.gz
tar -zxvf "${HOME}"/bao/pdns-4.1.x-linux.tar.gz -C "${HOME}"/bao/
yum install -y "${HOME}"/bao/pdns-4.1/*

yum install -y mariadb





local_ip=`ip address show | awk '/inet / {print $2}' | grep -v 127.0.0.1 | cut -d'/' -f1`
cp /etc/pdns-recursor/recursor.conf /etc/pdns-recursor/recursor.conf.bak
cat > /etc/pdns-recursor/recursor.conf <<EOF
#这里是最低限度的配置，剩下的不填写就是默认选项，默认配置可以参见：/etc/pdns-recursor/recursor.conf.bak

quiet=yes  # 设置静默模式为是
local-address=${local_ip}  # 设置本地地址为xxx.xxx.xxx.xxx
export-etc-hosts=on  # 开启从/etc/hosts导出
######forward-zones=tianye.com.=172.16.2.37:53,tianye.tianye.=172.16.2.37:53,.=114.114.114.114;223.5.5.5  # 设置转发区域
forward-zones-recurse=.=172.16.1.64:53;172.16.1.65:53;114.114.114.114;8.8.8.8  # 设置递归转发区域
daemon=yes  # 设置为守护进程模式
max-tcp-clients=400  # 设置最大TCP客户端数量为400
root-nx-trust=no  # 设置不信任根NX
version=no  # 设置版本隐藏
version-string=no  # 设置版本字符串隐藏

EOF



cat <<\Tay

====================================
【pdns-递归服务器】安装OK
====================================

注意：数据库连接地址没有配置（配置文件中是随意写的）
路径：/etc/pdns-recursor/recursor.conf

systemctl restart pdns-recursor.service
systemctl status pdns-recursor.service
systemctl enable pdns-recursor.service

Tay
